import request from '@/util/request'
import { Message } from 'element-ui';
import router from '@/router';

export  function loginAPI(data){
    return request.post('/api/login',data).then(res=>{
        console.log(res.data);
        if(res.status == 200){
        console.log(res.data);
        Message({
            message:res.msg,
            type:'success'
        })
        localStorage.setItem('user',JSON.stringify(res.data.token))
        router.push('/')
        }else{
            Message({
                message:res.data,
                type:'warning'
            })
        }
    })
}